using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Spread.Common.Features.Sample;
using FarPoint.Win.Spread.Model;
using FarPoint.Win.Chart;
using System.Reflection;
using FarPoint.Win.Spread.Data;

namespace Spread.Charts
{
    public partial class BasicCharts : BaseSampleControl
    {
        Dictionary<string, Dictionary<string, Type>> _chartTypes = new Dictionary<string, Dictionary<string, Type>>
        {
            {"Column", new Dictionary<string, Type>
            {
                { "Column", typeof(BarSeries)},
                { "Clustered", typeof(ClusteredBarSeries)},
                { "Stacked", typeof(StackedBarSeries)},
                { "Stacked 100%", typeof(StackedBarSeries)},
                { "High Low", typeof(HighLowBarSeries)},                
            }
            },
            {"Bar", new Dictionary<string, Type>
            {
                {"Bar", typeof(BarSeries) },
                {"Clustered", typeof(ClusteredBarSeries) },
                {"Stacked", typeof(StackedBarSeries) },
                {"Stacked 100%", typeof(StackedBarSeries) },
                {"High Low", typeof(HighLowBarSeries) },                
            }
            },
            {"Area", new Dictionary<string, Type>
            {
                {"Area", typeof(AreaSeries) },
                {"Stacked", typeof(StackedAreaSeries) },
                {"Stacked 100%", typeof(StackedAreaSeries) },
                {"High Low", typeof(HighLowAreaSeries) },
            }
            },
            {"Line", new Dictionary<string, Type>
            {
                {"Line", typeof(LineSeries) },
                {"Smoothed", typeof(LineSeries) },
                {"Stacked", typeof(StackedLineSeries) },
                {"Stacked 100%", typeof(StackedLineSeries) },
            }
            },
            {"Line With Marker", new Dictionary<string, Type>
            {
                {"Line WIth Marker", typeof(LineSeries) },
                {"Smoothed", typeof(LineSeries) },
                {"Stacked", typeof(StackedLineSeries) },
                {"Stacked 100%", typeof(StackedLineSeries) }
            }
            },
            {"Bubble", new Dictionary<string, Type>
            {
                {"Bubble", typeof(XYBubbleSeries) }
            }
            },
            {"XY", new Dictionary<string, Type>
            {
                {"Point", typeof(XYPointSeries) },
                {"Line", typeof(XYLineSeries) },
                {"Line With Marker", typeof(XYLineSeries) },
            }
            },
            {"XYZ", new Dictionary<string, Type>
            {
                {"Point", typeof(XYZPointSeries) },
                {"Line", typeof(XYZLineSeries) },
                {"Line With Marker", typeof(XYZLineSeries) },
                {"Surface", typeof(XYZSurfaceSeries) },
            }
            },
            {"Stock", new Dictionary<string, Type>
            {
                {"High Low Close", typeof(HighLowCloseSeries) },
                {"Open High Low Close", typeof(OpenHighLowCloseSeries) },
                {"Candle Stick", typeof(CandlestickSeries) }
            }
            },
            {"Pie", new Dictionary<string, Type>
            {
                {"Pie", typeof(PieSeries) },
                {"Exploded", typeof(PieSeries) },
            }
            },
            {"Doughnut", new Dictionary<string, Type>
            {
                {"Doughnut", typeof(PieSeries) },
                {"Exploded", typeof(PieSeries) },
            }
            },
        };
        SpreadDataBindingAdapter _dataAdapter;
        int rowCount = 0, colCount = 0;
        public BasicCharts()
        {
            InitializeComponent();
            Name = "Basic Chart Types";            

            //Init Controls
            _dataAdapter = new SpreadDataBindingAdapter() { Spread = fpSpread1, SheetName = "Sheet1", DataAutoCellTypes = false };
            _cbChartGroup.DataSource = _chartTypes.Keys.ToList();
            _cbShape.DataSource = Enum.GetNames(typeof(BarShape));
            _cbLegendPos.DataSource = Enum.GetNames(typeof(LegendPos));

            //Set Data
            SetDefaultData();

            _cbChartGroup.SelectedIndexChanged += _cbChartGroup_SelectedIndexChanged;
            _cbChartType.SelectedIndexChanged += _cbChartType_SelectedIndexChanged;
            _cbShape.SelectedIndexChanged += _cbShape_SelectedIndexChanged;
            _cbLegendPos.SelectedIndexChanged += _cbLegendPos_SelectedIndexChanged;
            _chb3DView.CheckedChanged += _chb3DView_CheckedChanged;
            _chbLegOrientation.CheckedChanged += _chbLegOrientation_CheckedChanged;
            _cbChartGroup_SelectedIndexChanged(_cbChartGroup, new EventArgs());            
        }
       
        private void _chbLegOrientation_CheckedChanged(object sender, EventArgs e)
        {
            fpSpread1_Sheet1.Charts[0].Model.LegendAreas[0].Vertical = _chbLegOrientation.Checked;
        }

        private void _cbLegendPos_SelectedIndexChanged(object sender, EventArgs e)
        {
            fpSpread1_Sheet1.Charts[0].Model.LegendAreas[0].LegendPos = (LegendPos)Enum.Parse(typeof(LegendPos), _cbLegendPos.SelectedItem.ToString());
        }

        private void _chb3DView_CheckedChanged(object sender, EventArgs e)
        {
            fpSpread1_Sheet1.Charts[0].ViewType = _chb3DView.Checked ? ChartViewType.View3D : ChartViewType.View2D;
        }

        private void _cbShape_SelectedIndexChanged(object sender, EventArgs e)
        {
            var shape = (BarShape)Enum.Parse(typeof(BarShape), _cbShape.SelectedItem.ToString());
            foreach (dynamic ser in fpSpread1_Sheet1.Charts[0].Model.PlotAreas[0].Series)
            {
                if (ser is BarSeries)
                    ser.BarShape = shape;
                else if (ser is HighLowBarSeries)
                    ser.BarShape = shape;
                else
                {
                    foreach (var dSer in ser.Series)
                        dSer.BarShape = shape;
                }
            }
        }

        private void _cbChartType_SelectedIndexChanged(object sender, EventArgs e)
        {
            var grpName = _cbChartGroup.SelectedItem.ToString();
            var typeName = _cbChartType.SelectedItem.ToString();
            var series = _chartTypes[grpName][typeName];
            _lShape.Visible = _cbShape.Visible = (grpName == "Column" || grpName == "Bar");

            fpSpread1_Sheet1.Charts.Clear();
            var cellRange = typeName == "High Low Close" ? new CellRange(1, 2, rowCount - 1, colCount - 2) : new CellRange(0, 0, rowCount, colCount);
            var view = _chb3DView.Checked ? ChartViewType.View3D : ChartViewType.View2D;
            fpSpread1_Sheet1.AddChart(cellRange, series, 600, 400, 50, 200, view, true);

            SetChartProperties(grpName, typeName);
            ShowPlotWithGridLines(fpSpread1_Sheet1.Charts[0].Model.PlotAreas[0]);
            fpSpread1_Sheet1.Charts[0].ContextMenuStrip = null;            
            
            if (_cbShape.Visible)
                _cbShape.SelectedIndex = 0;
            _cbLegendPos.SelectedItem = "Right";
            _chbLegOrientation.Checked = true;
        }

        private void ShowPlotWithGridLines(PlotArea plotArea)
        {
            plotArea.Depth = 0.5f;
            if (plotArea is YPlotArea)
            {
                (plotArea as YPlotArea).XAxis.MajorGridVisible = true;
                (plotArea as YPlotArea).YAxes[0].MajorGridVisible = true;
                (plotArea as YPlotArea).ZAxis.MajorGridVisible = true;
            }
            else if(plotArea is XYPlotArea)
            {
                (plotArea as XYPlotArea).XAxes[0].MajorGridVisible = true;
                (plotArea as XYPlotArea).YAxes[0].MajorGridVisible = true;
                (plotArea as XYPlotArea).ZAxis.MajorGridVisible = true;
            }
            else if(plotArea is XYZPlotArea)
            {
                (plotArea as XYZPlotArea).XAxes[0].MajorGridVisible = true;
                (plotArea as XYZPlotArea).YAxes[0].MajorGridVisible = true;
                (plotArea as XYZPlotArea).ZAxes[0].MajorGridVisible = true;
            }
        }

        private void SetChartProperties(string grpName, string typeName)
        {
            var chartType = grpName != typeName ? string.Join(" ", typeName, grpName) : grpName;
            //Set Header
            fpSpread1_Sheet1.Charts[0].Model.LabelAreas.Clear();
            fpSpread1_Sheet1.Charts[0].Model.LabelAreas.Add(new LabelArea { Text = chartType, Location = new PointF(0.5f, 0.05f), AlignmentX = 0.5f, AlignmentY = 0.5f });

            //Chart Group related changes
            if (grpName == "Bar")
                (fpSpread1_Sheet1.Charts[0].Model.PlotAreas[0] as YPlotArea).Vertical = false;
            else if(grpName == "Line")
            {
                foreach (dynamic lSer in fpSpread1_Sheet1.Charts[0].Model.PlotAreas[0].Series)
                {
                    if (!(lSer is StackedLineSeries))
                        lSer.PointMarker = new NoMarker();
                    else
                        foreach (dynamic ser in lSer.Series)
                            ser.PointMarker = new NoMarker();
                }
            }
            else if(grpName == "Doughnut")
                (fpSpread1_Sheet1.Charts[0].Model.PlotAreas[0] as PiePlotArea).HoleSize = 0.7f;

            //Chart Type related changes
            if (typeName == "Stacked 100%")
                foreach (dynamic ser in fpSpread1_Sheet1.Charts[0].Model.PlotAreas[0].Series)
                    ser.Percent = true;
            else if (typeName == "Smoothed")
                foreach (LineSeries lSer in fpSpread1_Sheet1.Charts[0].Model.PlotAreas[0].Series)
                    lSer.SmoothedLine = true;
            else if (typeName == "High Low Close")
                foreach (HighLowCloseSeries hlcSer in fpSpread1_Sheet1.Charts[0].Model.PlotAreas[0].Series)
                    hlcSer.CategoryNames.AddRange(fpSpread1_Sheet1.GetClipValue(1, 0, rowCount - 1, 1).Split('\n'));
            else if (typeName == "Exploded")
                foreach (PieSeries pieSer in fpSpread1_Sheet1.Charts[0].Model.PlotAreas[0].Series)
                    pieSer.PieDetachments.AddRange(Enumerable.Repeat(0.2f, pieSer.Values.Count).ToArray());
            else if (typeName == "Line")
                foreach (dynamic pSer in fpSpread1_Sheet1.Charts[0].Model.PlotAreas[0].Series)
                    pSer.PointMarker = new NoMarker();
        }

        private void _cbChartGroup_SelectedIndexChanged(object sender, EventArgs e)
        {
            string groupName = "Column";
            if(_cbChartGroup.SelectedItem!=null)
                groupName = _cbChartGroup.SelectedItem.ToString();            

            //Set Data for selected chart group
            switch (groupName)
            {
                case "Stock":
                    SetData(DataSource.GetStockData());
                    break;
                case "Pie":
                    SetData(DataSource.GetMarketShareData(1));
                    break;
                case "Doughnut":
                    SetData(DataSource.GetMarketShareData(1));
                    break;
                default:
                    SetDefaultData();
                    break;
            }
            _chb3DView.Checked = groupName == "XYZ" ? true : _chb3DView.Checked ;
            var chartTypes = _chartTypes.Where(x => x.Key == groupName).SelectMany(x => x.Value.Keys.ToList()).ToList();
            _cbChartType.DataSource = chartTypes;            
        }
        private void SetDefaultData()
        {
            ResetSheetData();
            var rnd = new Random();
            fpSpread1_Sheet1.SetClipValue(0, 0, 1, 8, "\tChrome\tFireFox\tIE\tSafari\tEdge\tOpera\tOther");
            for (int i = 1; i <= 4; i++)
            {
                fpSpread1_Sheet1.Cells[i, 0].Value = DateTime.Now.Year - i;
                for (int j = 1; j <= 7; j++)
                {
                    fpSpread1_Sheet1.Cells[i, j].Value = rnd.NextDouble().ToString("0.00");
                }
            }
            rowCount = 5; colCount = 8;
        }
        private void SetData(List<object> list)
        {
            ResetSheetData();
            int r = 0, c = 1;
            foreach (var prop in list[0].GetType().GetProperties().Skip(1))
            {
                fpSpread1_Sheet1.Cells[r, c].Value = prop.Name;
                c++;
            }
            _dataAdapter.DataSource = list;
            _dataAdapter.MapperInfo = new MapperInfo(1, 0, list.Count, c);
            _dataAdapter.FillSpreadDataByDataSource();
            rowCount = list.Count + 1;
            colCount = c;
        }
        private void ResetSheetData()
        {
            _dataAdapter.DataSource = null;
            fpSpread1_Sheet1.ClearRange(0, 0, rowCount + 1, colCount + 1, false, FarPoint.Win.Spread.ClipboardCopyOptions.All);
        }
    }
}


//
//BasicCharts.Designer.cs
//


namespace Spread.Charts
{
    partial class BasicCharts
    {
        /// <summary> 
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary> 
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Component Designer generated code

        /// <summary> 
        /// Required method for Designer support - do not modify 
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.fpSpread1 = new FarPoint.Win.Spread.FpSpread();
            this.fpSpread1_Sheet1 = new FarPoint.Win.Spread.SheetView();
            this._lChartGroup = new System.Windows.Forms.Label();
            this._cbChartGroup = new System.Windows.Forms.ComboBox();
            this._lChartType = new System.Windows.Forms.Label();
            this._cbChartType = new System.Windows.Forms.ComboBox();
            this._chb3DView = new System.Windows.Forms.CheckBox();
            this._lShape = new System.Windows.Forms.Label();
            this._cbShape = new System.Windows.Forms.ComboBox();
            this._lLegendPos = new System.Windows.Forms.Label();
            this._cbLegendPos = new System.Windows.Forms.ComboBox();
            this._chbLegOrientation = new System.Windows.Forms.CheckBox();
            this.pnlMain.SuspendLayout();
            this.pnlControls.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.fpSpread1)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.fpSpread1_Sheet1)).BeginInit();
            this.SuspendLayout();
            // 
            // pnlMain
            // 
            this.pnlMain.Controls.Add(this.fpSpread1);
            // 
            // pnlControls
            // 
            this.pnlControls.Controls.Add(this._chbLegOrientation);
            this.pnlControls.Controls.Add(this._cbLegendPos);
            this.pnlControls.Controls.Add(this._lLegendPos);
            this.pnlControls.Controls.Add(this._cbShape);
            this.pnlControls.Controls.Add(this._lShape);
            this.pnlControls.Controls.Add(this._chb3DView);
            this.pnlControls.Controls.Add(this._cbChartType);
            this.pnlControls.Controls.Add(this._lChartType);
            this.pnlControls.Controls.Add(this._cbChartGroup);
            this.pnlControls.Controls.Add(this._lChartGroup);
            // 
            // fpSpread1
            // 
            this.fpSpread1.AccessibleDescription = "";
            this.fpSpread1.Dock = System.Windows.Forms.DockStyle.Fill;
            this.fpSpread1.Location = new System.Drawing.Point(0, 0);
            this.fpSpread1.Name = "fpSpread1";
            this.fpSpread1.Sheets.AddRange(new FarPoint.Win.Spread.SheetView[] {
            this.fpSpread1_Sheet1});
            this.fpSpread1.Size = new System.Drawing.Size(477, 487);
            this.fpSpread1.TabIndex = 0;
            // 
            // fpSpread1_Sheet1
            // 
            this.fpSpread1_Sheet1.Reset();
            this.fpSpread1_Sheet1.SheetName = "Sheet1";
            // Formulas and custom names must be loaded with R1C1 reference style
            this.fpSpread1_Sheet1.ReferenceStyle = FarPoint.Win.Spread.Model.ReferenceStyle.R1C1;
            this.fpSpread1_Sheet1.ReferenceStyle = FarPoint.Win.Spread.Model.ReferenceStyle.A1;
            // 
            // _lChartGroup
            // 
            this._lChartGroup.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this._lChartGroup.AutoSize = true;
            this._lChartGroup.Location = new System.Drawing.Point(14, 18);
            this._lChartGroup.Name = "_lChartGroup";
            this._lChartGroup.Size = new System.Drawing.Size(70, 13);
            this._lChartGroup.TabIndex = 0;
            this._lChartGroup.Text = "Chart Group :";
            // 
            // _cbChartGroup
            // 
            this._cbChartGroup.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this._cbChartGroup.FormattingEnabled = true;
            this._cbChartGroup.Location = new System.Drawing.Point(29, 44);
            this._cbChartGroup.Name = "_cbChartGroup";
            this._cbChartGroup.Size = new System.Drawing.Size(121, 21);
            this._cbChartGroup.TabIndex = 1;
            // 
            // _lChartType
            // 
            this._lChartType.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this._lChartType.AutoSize = true;
            this._lChartType.Location = new System.Drawing.Point(14, 79);
            this._lChartType.Name = "_lChartType";
            this._lChartType.Size = new System.Drawing.Size(65, 13);
            this._lChartType.TabIndex = 2;
            this._lChartType.Text = "Chart Type :";
            // 
            // _cbChartType
            // 
            this._cbChartType.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this._cbChartType.FormattingEnabled = true;
            this._cbChartType.Location = new System.Drawing.Point(29, 109);
            this._cbChartType.Name = "_cbChartType";
            this._cbChartType.Size = new System.Drawing.Size(121, 21);
            this._cbChartType.TabIndex = 3;
            // 
            // _chb3DView
            // 
            this._chb3DView.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this._chb3DView.AutoSize = true;
            this._chb3DView.Location = new System.Drawing.Point(17, 151);
            this._chb3DView.Name = "_chb3DView";
            this._chb3DView.Size = new System.Drawing.Size(66, 17);
            this._chb3DView.TabIndex = 4;
            this._chb3DView.Text = "3D View";
            this._chb3DView.UseVisualStyleBackColor = true;
            // 
            // _lShape
            // 
            this._lShape.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this._lShape.AutoSize = true;
            this._lShape.Location = new System.Drawing.Point(17, 188);
            this._lShape.Name = "_lShape";
            this._lShape.Size = new System.Drawing.Size(44, 13);
            this._lShape.TabIndex = 5;
            this._lShape.Text = "Shape :";
            // 
            // _cbShape
            // 
            this._cbShape.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this._cbShape.FormattingEnabled = true;
            this._cbShape.Location = new System.Drawing.Point(29, 215);
            this._cbShape.Name = "_cbShape";
            this._cbShape.Size = new System.Drawing.Size(121, 21);
            this._cbShape.TabIndex = 6;
            // 
            // _lLegendPos
            // 
            this._lLegendPos.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this._lLegendPos.AutoSize = true;
            this._lLegendPos.Location = new System.Drawing.Point(20, 259);
            this._lLegendPos.Name = "_lLegendPos";
            this._lLegendPos.Size = new System.Drawing.Size(89, 13);
            this._lLegendPos.TabIndex = 7;
            this._lLegendPos.Text = "Legend Position :";
            // 
            // _cbLegendPos
            // 
            this._cbLegendPos.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this._cbLegendPos.FormattingEnabled = true;
            this._cbLegendPos.Location = new System.Drawing.Point(29, 288);
            this._cbLegendPos.Name = "_cbLegendPos";
            this._cbLegendPos.Size = new System.Drawing.Size(121, 21);
            this._cbLegendPos.TabIndex = 8;
            // 
            // _chbLegOrientation
            // 
            this._chbLegOrientation.AutoSize = true;
            this._chbLegOrientation.Checked = true;
            this._chbLegOrientation.CheckState = System.Windows.Forms.CheckState.Checked;
            this._chbLegOrientation.Location = new System.Drawing.Point(23, 335);
            this._chbLegOrientation.Name = "_chbLegOrientation";
            this._chbLegOrientation.Size = new System.Drawing.Size(100, 17);
            this._chbLegOrientation.TabIndex = 9;
            this._chbLegOrientation.Text = "Vertical Legend";
            this._chbLegOrientation.UseVisualStyleBackColor = true;
            // 
            // Introduction
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.Name = "Introduction";
            this.pnlMain.ResumeLayout(false);
            this.pnlControls.ResumeLayout(false);
            this.pnlControls.PerformLayout();
            ((System.ComponentModel.ISupportInitialize)(this.fpSpread1)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.fpSpread1_Sheet1)).EndInit();
            this.ResumeLayout(false);

        }

        #endregion

        private FarPoint.Win.Spread.FpSpread fpSpread1;
        private FarPoint.Win.Spread.SheetView fpSpread1_Sheet1;
        private System.Windows.Forms.Label _lChartType;
        private System.Windows.Forms.ComboBox _cbChartGroup;
        private System.Windows.Forms.Label _lChartGroup;
        private System.Windows.Forms.ComboBox _cbChartType;
        private System.Windows.Forms.ComboBox _cbShape;
        private System.Windows.Forms.Label _lShape;
        private System.Windows.Forms.CheckBox _chb3DView;
        private System.Windows.Forms.CheckBox _chbLegOrientation;
        private System.Windows.Forms.ComboBox _cbLegendPos;
        private System.Windows.Forms.Label _lLegendPos;
    }
}


//
//DataService.cs
//

using Spread.Common.DataStore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Spread.Charts
{
    public class DataSource
    {
        static Random rnd = new Random();
        public static List<object> GetMarketShareData(int count)
        {
            var data = new List<object>();
            for(int i = 1; i <= count; i++)
                data.Add(new { Year = DateTime.Now.Year - i, North = rnd.Next(100, 500), East=rnd.Next(100,500), West = rnd.Next(100,500), South = rnd.Next(100,500), NorthEast=rnd.Next(100,500) });
            return data;
        }
        public static List<object> GetStockData()
        {
            var data = new List<object>();
            var startDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month - 2, 1);
            for(int i = 0; i < 5; i++)
            {
                data.Add(new
                {
                    Date = startDate.AddDays(i).ToShortDateString(),
                    Open = rnd.Next(40, 60),
                    High = rnd.Next(60, 70),
                    Low = rnd.Next(30, 40),                    
                    Close = rnd.Next(40, 60),                    
                });
            }
            return data;
        }
        public static List<object> GetStudentsScore()
        {
            var data = new List<object>();
            for(int i = 1; i <= 20; i++)
                data.Add(new {Name = "Class"+((i%4)+1), Score = rnd.Next(20,99)});
            return data;
        }
        public static List<object> GetPolarData()
        {
            var data = new List<object>();
            return data;
        }
        public static List<object> GetSalesStageData()
        {
            var data = new List<object>();
            data.Add(new { Stage = "Leads", Value = 100 });
            data.Add(new { Stage = "Emails Sent", Value = 70 });
            data.Add(new { Stage = "Replies", Value = 45 });
            data.Add(new { Stage = "Quotes", Value = 25 });
            data.Add(new { Stage = "Purchases", Value = 5 });
            return data;
        }
        public static List<object> GetProfitData()
        {
            var data = new List<object>();
            data.Add(new { Period = (DateTime.Now.Year-2).ToString(), Profit = rnd.Next(1000,5000) });
            data.Add(new { Period = "Jan", Profit = rnd.Next(100, 200) });
            data.Add(new { Period = "Feb", Profit = rnd.Next(100, 200) });
            data.Add(new { Period = "Mar", Profit = -rnd.Next(50, 100) });
            data.Add(new { Period = "Apr", Profit = -rnd.Next(50, 100) });
            data.Add(new { Period = "May", Profit = -rnd.Next(50, 100) });
            data.Add(new { Period = "Jun", Profit = rnd.Next(100, 150) });
            data.Add(new { Period = "Jul", Profit = rnd.Next(100, 150) });
            data.Add(new { Period = "Aug", Profit = rnd.Next(100, 150) });
            var total = data.Sum(x => (x as dynamic).Profit);
            data.Add(new { Period = "Total", Profit = total });
            return data;
        }
        public static List<object> GetBoxWhiskerData()
        {
            var data = new List<object>();
            var cheese = new string[] { "Asiago", "Gouda", "Havarti", "Swiss" };
            for(int i = 0; i <= 15; i++)
                data.Add(new { Cheese = cheese[i % cheese.Count()], Store1 = rnd.Next(5, 30), Store2 = rnd.Next(5, 30), Store3 = rnd.Next(5, 30) });
            return data;
        }

        public static List<object> GetHierarchicalData()
        {
            var data = new List<object>();
            data.Add(new { Continent = "America", Country = "US".ToString(), GDPPrice = 19362 });
            data.Add(new { Continent = "America", Country = "Brazil".ToString(), GDPPrice = 2081 });
            data.Add(new { Continent = "America", Country = "Canada".ToString(), GDPPrice = 1640 });
            data.Add(new { Continent = "Asia", Country = "China".ToString(), GDPPrice = 2439 });
            data.Add(new { Continent = "Asia", Country = "Japan".ToString(), GDPPrice = 4884 });
            data.Add(new { Continent = "Asia", Country = "India".ToString(), GDPPrice = 2439 });
            data.Add(new { Continent = "Europe", Country = "Germany".ToString(), GDPPrice = 3652 });
            data.Add(new { Continent = "Europe", Country = "France".ToString(), GDPPrice = 2575 });
            data.Add(new { Continent = "Europe", Country = "Italy".ToString(), GDPPrice = 1921 });
            data.Add(new { Continent = "Europe", Country = "UK".ToString(), GDPPrice = 2565 });
            return data;
        }
    }
}

